import time

from selenium.webdriver.common.by import By

from common.Utils import BlogDriver
from tests.BlogLogin import BlogLogin


class BlogList:
    url = ""
    driver = ""
    def __init__(self):
        self.url = "http://8.137.19.140:9090/blog_list.html"
        self.driver = BlogDriver.driver
        self.driver.get(self.url)
    # 已登录状态下
    def blogListTest(self):
        # 是否有一篇博客相关的元素
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > div.date")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > div.desc")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > div.desc")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > a")
        BlogDriver.getScreenshot()

    # 未登录状态下无法打开列表页
    def logoutBlogListDetail(self):
        self.driver.get(self.url)
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container-login > div > h3")
        BlogDriver.getScreenshot()



